﻿@page "/login"
@attribute [AllowAnonymous]
@inject IStringLocalizer<Login> L
@inject IStringLocalizer<SharedResource> LS

<div class="d-flex justify-center">
    <img src="full-stack-hero-logo.png" Style="height:120px" />
</div>
<div class="fsh-center-text">
    <MudText Typo="Typo.h4" GutterBottom="true">Sign In</MudText>
    <MudText>@L["Enter your credentials to get started."]
    </MudText>
</div>
<br />
<EditForm Model="@_tokenRequest" OnValidSubmit="SubmitAsync">
    <MudGrid>
        <DataAnnotationsValidator />
        <CustomValidation @ref="_customValidation" />
        <MudItem xs="12">
            <MudTextField T="string" Label="@L["E-mail"]" Variant="Variant.Outlined" @bind-Value="_tokenRequest.Email"
                For="@(() => _tokenRequest.Email)" />
        </MudItem>
        <MudItem xs="12">
            <MudTextField Label="@L["Password"]" Variant="Variant.Outlined" @bind-Value="_tokenRequest.Password"
                For="@(() => _tokenRequest.Password)" InputType="@_passwordInput" Adornment="Adornment.End"
                AdornmentIcon="@_passwordInputIcon" OnAdornmentClick="TogglePasswordVisibility" />
        </MudItem>
        <MudItem xs="12">
            <MudTextField T="string" Label="@L["Tenant"]" Variant="Variant.Outlined" @bind-Value="TenantId"
                For="@(() => TenantId)" Required />
        </MudItem>
        
        <MudItem xs="12" md="6">
            <MudButton StartIcon="@Icons.Filled.AppRegistration" Link="/users/self-register">@L["Register?"]</MudButton>
        </MudItem>
         <MudItem xs="12" md="6">
            <MudButton StartIcon="@Icons.Filled.LockReset" Link="/account/forgot-password">@L["Forgot password?"]</MudButton>
        </MudItem>
        <MudItem xs="12" Class="d-flex justify-center">
            <MudButton ButtonType="ButtonType.Submit" Disabled="BusySubmitting" Variant="Variant.Filled"
                Color="Color.Primary" Size="Size.Large" StartIcon="@Icons.Filled.Login" Style="width: 100%;">@L["Sign In"]</MudButton>
        </MudItem>
        <MudItem xs="12">
            <MudButton StartIcon="@Icons.Filled.Password" OnClick="FillAdministratorCredentials">@L["Fill Administrator Credentials"]</MudButton>
        </MudItem>
    </MudGrid>
</EditForm>